
// import * as mqtt from 'mqtt/dist/mqtt.min.js';

/**
 * MQTT服务类
 *
 * npm install mqtt@3.0.0 -S
 * npm uninstall mqtt
 */
export class MqttService {

  static MQTT_SERVICE = 'mqtt://192.168.2.105:61613';
  static MQTT_USERNAME = 'guest';
  static MQTT_PASSWORD = '123456';
  static MQTT_CLIENTID = 'mqttx_155ecbab';
  static MQTT_TOPIC = 'mqttTopic';

  constructor() {
  }

  static connect(){
    // const options = {
    //   username: MqttService.MQTT_USERNAME,
    //   password: MqttService.MQTT_PASSWORD,
    //   clientId: MqttService.MQTT_CLIENTID,
    //   connectTimeout: 4000,
    //   clean: true,
    // };
    // const client = mqtt.connect('127.0.0.1', options);
    // console.log(client);
    // client.on('connect', () => {
    //   client.subscribe(MqttService.MQTT_TOPIC, (error:any) => {
    //     if (!error) {
    //       console.log('订阅成功');
    //     } else {
    //       console.log('订阅失败');
    //     }
    //   });
    // });
  }

}
